package lesson4;

import java.util.Objects;

public class Student extends Person{
    private String stuId;

    public Student() {
    }

    public Student(String stuId) {
        this.stuId = stuId;
    }

    public Student(String name,int age,String stuId) {
        super(name,age);
        this.stuId = stuId;
    }



    @Override
    public boolean equals(Object o){
        //判断地址
        if(this == o){
            return true;
        }
        //判断类型
        if(o instanceof Student){
            Student student = (Student) o;
            //if(this.stuId.equals(student.stuId) && this.getAge() == student.getAge() && this.getName().equals(student.getName())){
            if(this.stuId.equals(student.stuId) && super.equals(student)){
                return true;
            }
        }
        return false;
    }


    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), stuId);
    }

    public String getStuId() {
        return stuId;
    }

    public void setStuId(String stuId) {
        this.stuId = stuId;
    }

    @Override
    public String toString() {
        return "Student{" +
                super.toString()+
                "stuId='" + stuId + '\'' +
                '}';
    }
}
